﻿using NUnit.Framework;

namespace System.Lua.Tests
{
    [TestFixture]
    public class LuaWriteTableTest : LuaWriterTest
    {
        [Test(Description = "Writes the start of a Lua table.")]
        public void WriteStartTableTest()
        {
            string result = GetLuaWriterResult(luaWriter => luaWriter.WriteStartTable());

            Assert.AreEqual("{ ", result);
        }

        [Test(Description = "Writes the start of a positional Lua table field.")]
        public void WritePositionalStartTableFieldTest()
        {
            string result = GetLuaWriterResult(luaWriter => luaWriter.WriteStartTableField());

            Assert.AreEqual(result, String.Empty);
        }

        [Test(Description = "Writes the start of a named Lua table field.")]
        public void WriteNamedStartTableFieldTest()
        {
            const string fieldName = "field";

            string result = GetLuaWriterResult(luaWriter => luaWriter.WriteStartTableField(fieldName));

            Assert.AreEqual("field = ", result);
        }

        [Test(Description = "Writes the end of a Lua table field.")]
        public void WriteEndTableFieldTest()
        {
            string result = GetLuaWriterResult(luaWriter => luaWriter.WriteEndTableField());

            Assert.AreEqual(", ", result);
        }

        [Test(Description = "Writes the end of a Lua table.")]
        public void WriteEndTable()
        {
            string result = GetLuaWriterResult(luaWriter => luaWriter.WriteEndTable());

            Assert.AreEqual("}", result);
        }

    }
}
